import React,{Component} from 'react'
import {bindActionCreators} from'redux'
import PropTypes from 'prop-types'
import {connect} from 'react-redux'
import RegisterContent from '../components/RegisterContent'
import * as TodoActions from '../actions';

const Register = ({register, actions}) => (
  <div>
    <RegisterContent registerSuccess = { actions.registerSuccess } registerData = {register} registerAccount = {actions.registerAccount}/>
  </div>
) 

Register.propTypes = {
  register:PropTypes.object.isRequired,
  actions:PropTypes.object.isRequired,
}

const mapStateToProps = state =>({     //把state的部分东东给到组件，并以属性方式访问
    register:state.register
})

const mapDispatchToProps = dispatch => {  //把全局reducer的函数（自动分发信息）给到组件，并以属性方式访问（挂载在组件属性中）
    console.log(TodoActions);
    return {actions:bindActionCreators(TodoActions, dispatch)}
}


export default connect(mapStateToProps, mapDispatchToProps)(Register)
